<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.systop.core.dao.support.Page, com.systop.ltbook.notes.model.Notes" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@include file="/common/taglibs.jsp"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="${ctx}/styles/style.css">
<style type="text/css">

.title{
	background-color:#FAFAFA;
	line-height: 30px;
	font-size: 14px;
	font-weight: bold;
}
td{
	line-height: 30px;
}
input{
	border:1px solid #D9D9D9; 
}
</style>
</head>
<body>
<form id="queryForm" action="index.do" method="post" style="margin: 0px;">
<table align="center"" border="0" width="790">
  <tr><td>
   &nbsp;标题：<s:textfield name="title" cssStyle="width:150px;"/>
   &nbsp;&nbsp;&nbsp;&nbsp;日期从
   <s:textfield name="strDate" cssStyle="width:80px;"/>
   &nbsp;至&nbsp;<s:textfield name="endDate" cssStyle="width:80px;"/>
   <span style="cursor: pointer;" onclick="query()">
     &nbsp;&nbsp;<img src="${ctx}/images/icons/zoom.gif">查询
   </span>
  </td>
  <td align="right" valign="middle">
  	<a href="edit.do" title="编写日志"><img src="${ctx}/images/icons/file_add.gif"> <b>添加日志</b></a>
  </td>
  </tr>
</table>
</form>
<table align="center"" border="0" width="790" cellpadding="0" cellspacing="0" style="border: 1px solid #C0C0C0; ">
  <tr class="title">
  	<td width="40" align="center">No.</td>
  	<td width="450">&nbsp;标&nbsp;&nbsp;题</td>
  	<td width="150">日&nbsp;期</td>
  	<td width="150" align="center">操&nbsp;作</td>
  </tr>
 <%
  Page p = (Page)request.getAttribute("page");
  int i = 0;
  if (p.getData() != null && !p.getData().isEmpty()){
    for(Object o : p.getData()){
	  i++;
	  Notes n  = (Notes)o;
 %>
  <tr onmouseover="this.style.backgroundColor='#FAFAFA'" onmouseout="this.style.backgroundColor='#ffffff'">
  	<td width="40" align="center">  <%=i%></td>
  	<td width="430">
  	  <a href="view.do?model.id=<%=n.getId()%>" target="_blank"><%=n.getTitle()%></a>
  	</td>
  	<td width="120">
  		<%=n.getCreateDate()%>
  	</td>
  	<td width="100" align="center"> 
  	  <a href="edit.do?model.id=<%=n.getId()%>"><img src="${ctx}/images/icons/modify.gif" title="修改日志"></a>&nbsp;
  	  <a href="#" onclick="remove('<%=n.getId()%>')"><img src="${ctx}/images/icons/delete.gif" title="删除日志"></a>
  	</td>
  </tr>
<%
    }
  }
 %>
  <s:iterator value="#{page.data}" var="note">
  </s:iterator>
</table>
<table width="790" align="center">
  <tr>
  <td align="right">
    <div>
	<span class="pagecss">
	&nbsp;&nbsp;
	<a href="index.do?pageNo=1"> 首页</a>
	&nbsp;
	<% if (p.hasPreviousPage()){ %>
	<a href="index.do?pageNo=<%=p.getPageNo() - 1%>"> 上一页</a>
	<% } else { %>
	上一页
	<% } %>
	&nbsp;
	<% if (p.getHasNextPage()){ %>
	 <a href="index.do?pageNo=<%=p.getPageNo() + 1 %>"> 下一页</a>
	<% } else { %>
	 下一页
	<% } %>
	&nbsp;
	<a href="index.do?pageNo=<%=p.getPages()%>"> 尾页</a>
	&nbsp;&nbsp;
	第<font color="red"><%=p.getPageNo()%></font>页/共<font color="red"><%=p.getPages()%></font>页
	&nbsp;&nbsp;
	第<input type="text" id="goToPageNum" style="width:25px; margin: 0px 2px 0px 2px;">页&nbsp;
	<span style="cursor: pointer;" onclick="gotoPg()"><b>GO</b></span>
	</span>
	</div>
  </td>
  </tr>
</table>
<script type="text/javascript">
	function gotoPg(){
		pgNo = document.getElementById("goToPageNum").value;
		if (pgNo != null && pgNo.length > 0){
			if (!isNaN(pgNo)){
				window.location.href="index.do?pageNo=" + pgNo;
			}else{
				alert('跳转页码必须是数字!');
			}
		}
	}
	function query(){
		document.getElementById("queryForm").submit();
	}
	
	function remove(id){
		if(confirm("确认要删除日志吗?")){
			window.location.href="remove.do?model.id=" + id;
		}
	}
</script>
</body>
</html>